home *** CD-ROM | disk | FTP | other *** search
- Path: galaxy.ucr.edu!csamaras
- From: csamaras@ucrengr.ucr.edu (Constantine Samares)
- Newsgroups: comp.lang.c++
- Subject: Dynamically allocating 2-dim arrays
- Date: 5 Apr 1996 22:41:22 GMT
- Organization: University of California, Riverside
- Message-ID: <4k47ii$ppa@galaxy.ucr.edu>
- NNTP-Posting-Host: spidey.ucr.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Hello all,
-
- Does anyone out there know the "correct" way of dynamically allocating a
- 2-dimensional array in C++? This is the problem I'm running into:
-
- -----------------------------------------
- void main()
- {
- int xsize = 20, ysize = 25;
- int** matrix;
-
- matrix = new int[xsize][ysize];
- }
- -----------------------------------------
-
- The compiler (g++) gloriously stops compiling with the following error:
-
- test.cc: In function `int main(...)':
- test.cc:6: assignment to `int **' from `int (*)[1]'
-
- It doesn't like "int* matrix", "int matrix[][]", or "int* matrix[]" either.
- ----------- -------------- -------------
-
- Any suggestions?
-
- Thanx,
-
- -CT
-